package com.ericpol.Selenium;

import org.openqa.selenium.By;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import com.ericpol.pageObjectPattern.SeleniumBaseSuperClass;

public class BananasTestClass extends SeleniumBaseSuperClass{

	@Test
	public void shouldBePossibleToLogin() throws Exception {
		// given
		driver.get("http://demo.bananascrum.com");

		// when
		insertText(By.id("login"), "admin");
		insertText(By.id("password"), "password");
		click(By.name("commit"));

		// then
		assertThatPageContainsText("Logout");

	}
	
	@Test(dataProvider = "failedTestsData")
	public void shouldNotBePossibleToLoginWithEmptyLogin(String login, String password) throws Exception {
		// given
		driver.get("http://demo.bananascrum.com");

		// when
		insertText(By.id("login"), login);
		insertText(By.id("password"), password);
		click(By.name("commit"));

		// then
		assertThatPageContainsText("Login failed");
	}
	@DataProvider
	public Object[][] failedTestsData() {
		return new Object[][]{
				{ " ", " " },
				{ "adminDupa", "password" },
				{ "admin", "passwordDupa" }
		};
	}
	
}
